import React,{useState,useEffect} from 'react'
import { reqgetnew,reqgetbanner,reqgetindexgoods } from '../../http/api'
import Header from "../../components/Header/Header"
import New from './components/New/New'
import Banner from './components/Banner/Banner'
import Cate from './components/Cate/Cate'
export default function Home() {
  const [newgoods,setNew] = useState([])
  const [banner,setBnner] = useState([])
  const [goods,setGoods] = useState([])
  const [n,setN] = useState([0])
  useEffect(()=>{
    //请求新人专享
    reqgetnew().then(res=>{
      setNew(res.data.list)
    })
    //轮播
    reqgetbanner().then(res=>{
      setBnner(res.data.list)
    })
    //首页选项卡
    reqgetindexgoods().then(res=>{
      setGoods(res.data.list)
    })       
  },[]);
  return (
    <div>
        <Header></Header>
        <New newgoods={newgoods}></New>
        <Banner banner={banner}></Banner>
        <Cate goods={goods} n={n} onChangeN={v=>setN(v)}></Cate>
    </div>
  )
}

